package cn.semes.system.controller;

import cn.semes.basic.query.BaseQuery;
import cn.semes.basic.util.AjaxResult;

import cn.semes.basic.util.PageList;
import cn.semes.system.domain.Systemdictionarytype;
import cn.semes.system.service.ISystemTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/systyp")
public class SystemTypeController {
    
    @Autowired
    private ISystemTypeService service;

    // 分页查
    @PostMapping()
    public PageList<Systemdictionarytype> queryByPage(@RequestBody BaseQuery query) {
        return service.queryByPage(query);
    }

    @PutMapping()
    public AjaxResult addOrUpdate(@RequestBody Systemdictionarytype Systemdictionarytype) {
        if (null != Systemdictionarytype.getId()) {
            // 修改
            service.update(Systemdictionarytype);
        } else {
            // 添加
            service.add(Systemdictionarytype);
        }
        return AjaxResult.me().success();
    }

    @DeleteMapping("/{id}")
    public AjaxResult delete(@PathVariable("id") Long id) {
        service.delete(id);
        return AjaxResult.me().success();
    }

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @PatchMapping()
    public AjaxResult batchDelete(@RequestBody List<Long> ids) {
        System.out.println(ids);
        service.batchDelete(ids);
        return AjaxResult.me().success();
    }
}
